const { defineConfig } = require('@vue/cli-service')
const path = require('path');
let proxyObj = {}
proxyObj['/'] = {

  ws: false,
  target: 'http://127.0.0.1:9999', // 后端地址
  changeOrigin: true, // 修改请求头Origin
  pathRewrite: { '^/': '/' }, // 重写路径（去除/api前缀）

}
proxyObj['/ws'] = {
  ws: true,
  target: 'ws://127.0.0.1:9999', // 后端地址

}


module.exports = defineConfig({
  devServer: {
    // host: 'localhost',
    // proxy: proxyObj,

  },
  lintOnSave: false,
  configureWebpack: {
    devtool: 'source-map',
  },
  chainWebpack: (config) => {
    config.plugin('define').tap((definitions) => {
      Object.assign(definitions[0], {
        __VUE_OPTIONS_API__: 'true',
        __VUE_PROD_DEVTOOLS__: 'false',
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
      })
      return definitions
    }),
      config.resolve.alias.set(false, resolve('net')) // 设置 @ 为 src 目录的别名
        .end()
  },


})
function resolve(dir) {
  return path.join(__dirname, dir);
}